package com.example.mapp;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.*;

import com.example.entity.maintenance.HydpressHalfMon;
import com.example.entity.maintenance.HydpressHalfYear;
import com.example.entity.maintenance.HydpressQuarter;
import com.example.entity.maintenance.HydpressYear;
import com.example.ext.entity.maintenance.ExtHydpressHalfMon;
import com.example.mapp.buildSql.MaintMappSql;

/**
 * Created by douyx on 2017/10/29.
 */
@Mapper
public interface HydpressMapp {
	/**
	 * 新增液压电梯半月保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into hydpress_half_mon (alarm_intercom,anti_collision_protector," +
			"automatic_closing_device,automatic_reset,car_deck_accuracy,"
			+ "car_door_run,car_lighting,car_overhaul_switch,car_top,cardoor_lock_contact,cartop_overhaul_device," +
			"display_command_button,electrical_contact,"
			+ "encoder,gate_bypass_device,guide_shoe_cup,hydraulic_oil_pipe,hydraulic_plunger," +
			"landing_sill,layer_locking_length,limiter_each_part,"
			+ "maintenance_end_date,maintenance_start_date,maintenance_user_sign_id1," +
			"maintenance_user_sign_id2,motor,operating_device,pit,pit_stop,"
			+ "room_environment," +
			"sth_parts,storey_display,tank,type,well_illumination,elevator_num," +
			"maintenance_user_name,maintenance_user_name2,maintenance_user_id1,maintenance_user_id2," +
			"maintenance_party_id,is_in_time_maint," +
			"maintenancen_used_time,change_info, summary, xcfhcs,ldbh,other_photos) VALUES" +
			" (#{alarmIntercom},"
			+ "#{antiCollisionProtector},#{automaticClosingDevice},#{automaticReset},#{carDeckAccuracy}," +
			"#{carDoorRun},#{carLighting},#{carOverhaulSwitch},"
			+ "#{carTop},#{cardoorLockContact},#{cartopOverhaulDevice},#{displayCommandButton}," +
			"#{electricalContact},#{encoder},#{gateBypassDevice},"
			+ "#{guideShoeCup},#{hydraulicOilPipe},#{hydraulicPlunger},#{landingSill},#{layerLockingLength}," +
			"#{limiterEachPart},#{maintenanceEndDate},"
			+ "#{maintenanceStartDate},#{maintenanceUserSignId1},#{maintenanceUserSignId2},#{motor}," +
			"#{operatingDevice},#{pit},#{pitStop},#{roomEnvironment},"
			+ "#{sthParts},#{storeyDisplay}," +
			"#{tank},#{type},#{wellIllumination},#{elevatorNum},#{maintenanceUserName},#{maintenanceUserName2}," +
			"#{maintenanceUserId1},#{maintenanceUserId2}," +
			"#{maintenancePartyId}," +
			"#{isInTimeMaint},#{maintenancenUsedTime},#{changeInfo},#{summary},#{xcfhcs},#{ldbh},#{otherPhotos}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public int addHydpressHalfMon(HydpressHalfMon hydpressHalfMon) throws Exception;


	/**
	 * 更新液压电梯半月保数据
	 * @param map
	 * @return
	 * @throws Exception
	 */
	@Update("update hydpress_half_mon set safe_user_sign_id2=#{safeUserSignId2}," +
			"safe_user_name=#{safeUserName},safe_user_sign_time=#{safeUserSignTime}," +
			"status=#{status},used_party_opt=#{usedPartyOpt} where id=#{elevatoriMonId} ")
	public void updateEscalatorHalfMon(Map<String,Object> map) throws Exception;

	/**
	 * 获取液压电梯维保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@SelectProvider(type = MaintMappSql.class, method = "findHydpressList")
	List<ExtHydpressHalfMon> findHydpressList(ExtHydpressHalfMon hydpressHalfMon) throws Exception;

	@Select(" SELECT * from hydpress_half_mon where id = #{id}")
	HydpressHalfMon queryHydpressHalfMon(String id) throws Exception;

	/**
	 * 新增液压电梯季度保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into hydpress_quarter (car_shoe_roller,door_guide_shoe,electrical_safety_device,energy_dissipation_buffer,fire_switch,"
			+ "half_mon_id,hand_down_valve,hand_pump,limiter_tensioning_wheel,limiter_wheel_wire,oil_temperature_monitor,plunger_side_shoe,"
			+ "safety_relief_valve,transmission_wire_rope) VALUES (#{carShoeRoller},#{doorGuideShoe},#{electricalSafetyDevice},#{energyDissipationBuffer},"
			+ "#{fireSwitch},#{halfMonId},#{handDownValve},#{handPump},#{limiterTensioningWheel},#{limiterWheelWire},#{oilTemperatureMonitor},"
			+ "#{plungerSideShoe},#{safetyReliefValve},#{transmissionWireRope}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public int addHydpressQuarter(HydpressQuarter hydpressQuarter) throws Exception;

	@Select(" SELECT * from hydpress_quarter where half_mon_id = #{halfMonId}")
	HydpressQuarter queryHydpressQuarter(String halfMonId) throws Exception;
	
	/**
	 * 新增液压电梯半年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into hydpress_half_year (bleed_operation,control_cabinet,control_cabinet_terminals,"
			+ "guide_wheel,limiter_wire_rope,plunger_spacing_device,quarter_id,suspension_wire_rope,updown_limit_switch,wire_head_combination)"
			+ " VALUES (#{bleedOperation},#{controlCabinet},#{controlCabinetTerminals},#{guideWheel},"
			+ "#{limiterWireRope},#{plungerSpacingDevice},#{quarterId},#{suspensionWireRope},#{updownLimitSwitch},#{wireHeadCombination}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public int addHydpressHalfYear(HydpressHalfYear hydpressHalfYear) throws Exception;

	@Select(" SELECT * from hydpress_half_year where quarter_id = #{quarterId}")
	HydpressHalfYear queryHydpressHalfYear(Long quarterId) throws Exception;
	
	/**
	 * 新增液压电梯年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into hydpress_year (car_weighing_device,guide_bracket,half_year_id,insulation_performance_test,limiter_safetyclamp_test,mounting_bolt,"
			+ "power_mounting_bolts,relay_contact,safety_clamp_holder,storey_gate_device,traveling_cable,buffer,car_cylinder_guide,car_subsidence_test,mounting_bolts) VALUES (#{carWeighingDevice},#{guideBracket},"
			+ "#{halfYearId},#{insulationPerformanceTest},#{limiterSafetyclampTest},#{mountingBolt},#{powerMountingBolts},#{relayContact},#{safetyClampHolder},"
			+ "#{storeyGateDevice},#{travelingCable},#{buffer},#{carCylinderGuide},#{carSubsidenceTest},#{mountingBolts}) ")
	public int addHydpressYear(HydpressYear hydpressYear) throws Exception;
	
	@Select(" SELECT * from hydpress_year where half_year_id = #{halfYearId}")
	HydpressYear queryHydpressYear(Long halfYearId) throws Exception;
}
